package com.itheima.health.config;

import com.itheima.health.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * 配置类，注册web层相关组件
 */
@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    /**
     * 注册自定义拦截器
     *
     * @param registry
     */
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("开始注册自定义拦截器...");
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**/**")
                .excludePathPatterns("/user/**",
                        "/validatecode/backendSend4Login.do",
                        "/validatecode/send4Order.do",
                        "/order/**",
                        "/setmeal/getSetmeal.do",
                        "/setmeal/findFullSetmealById.do",
                        "/setmeal/findById.do");

    }


}
